package logic

import (
	"bw-renting/api/internal/svc"
	"bw-renting/api/internal/types"
	"bw-renting/user-rpc/userclient"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
	return &SendSmsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// TODO: 发送验证码
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) (resp *types.Data, err error) {
	// todo: add your logic here and delete this line
	d, _ := l.svcCtx.UserServer.UserSendMobile(l.ctx, &userclient.UserSendMobileReq{
		Mobile: req.Mobile,
	})
	return &types.Data{
		Message: d.Code,
	}, nil
}
